//
//  MyControlUilt.m
//  WinesMall
//
//  Created by Isaac on 16/6/24.
//  Copyright © 2016年 Isaac. All rights reserved.
//

#import "MyControlUilt.h"

@implementation MyControlUilt

+(UIButton *)initButtonWithFrame:(CGRect)frame title:(NSString *)title titleColor:(UIColor *)titleColor backGroundColor:(UIColor *)backGroundColor cornerRadius:(CGFloat)cornerRadius target:(id)sender action:(SEL)action {
    UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
    myButton.frame = frame;
    [myButton setTitle:title forState:UIControlStateNormal];
    [myButton setTitleColor:titleColor forState:UIControlStateNormal];
    myButton.backgroundColor = backGroundColor;
    if (cornerRadius > 0) {
        myButton.layer.cornerRadius = cornerRadius;
        myButton.clipsToBounds = YES;
    }
    [myButton addTarget:sender action:action forControlEvents:UIControlEventTouchUpInside];
    
    return myButton;
}

#pragma 快捷创建UILabel
+ (UILabel *)createLabelWithFrame:(CGRect)frame labelText:(NSString* )labelText backColor:(UIColor *)backColor Font:(UIFont *)font TextColor:(UIColor *)textColor SuperView:(UIView *)superView {
    UILabel *label = [[UILabel alloc]initWithFrame:frame];
    label.text = labelText;
    label.font = font;
    label.textColor = textColor;
    if (backColor != nil) {
        label.backgroundColor = backColor;
    }
    
    [superView addSubview:label];
    return label;
}

#pragma mark -- 创建button
+ (UIButton *)createButtonWithFrame:(CGRect) frame Title:(NSString *)title TiTleColor:(UIColor *)color SuperView:(UIView *)superView Font:(UIFont *)font BackColor:(UIColor *)backColor{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = frame;
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:color forState:UIControlStateNormal];
    btn.titleLabel.font = font;
    [btn setBackgroundColor:backColor];
    [superView addSubview:btn];
    
    return btn;
}

#pragma mark -- 创建textF
+ (UITextField *)createTextFieldWithFrame:(CGRect) frame
                                    Title:(NSString *)title
                                TextColor:(UIColor *)color
                                SuperView:(UIView *)superView
                                     Font:(UIFont *)font
                                BackColor:(UIColor *)backColor {
    
    UITextField *textF = [[UITextField alloc]initWithFrame:frame];
    textF.placeholder = title;
    textF.textColor = color;
    [superView addSubview:textF];
    textF.font = font;
    textF.backgroundColor = backColor;
    
    return textF;
    
}

#pragma mark -- 创建textF
+ (UIImageView *)createImageViewWithFrame:(CGRect) frame
                                SuperView:(UIView *)superView
                                BackColor:(UIColor *)backColor {
    UIImageView *imagV = [[UIImageView alloc]initWithFrame:frame];

//    UIImageView *imagV = [[UIImageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 22, 14, 6, 12)];
//    imagV.image = [UIImage imageNamed:@"页面箭头"];
    if (backColor != nil) {
        imagV.backgroundColor = backColor;
    }
    [superView addSubview:imagV];
    
    return imagV;
}


@end
